package com.sec.android.app.myfiles.mockclass;

import org.powermock.api.mockito.PowerMockito;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.powermock.api.mockito.PowerMockito.doNothing;

/**
 * Created by jaebae on 2016-07-08.
 */
public class FileOutputStreamMock {
    public static FileOutputStream createMock(final File file) {
        final FileOutputStream outputStream = PowerMockito.mock(FileOutputStream.class);

        try {
            doNothing().when(outputStream).write(any(byte[].class), anyInt(), anyInt());
            doNothing().when(outputStream).flush();
            doNothing().when(outputStream).close();
        } catch (IOException e) {
            //DO NOTHING
        }

        return outputStream;
    }
}
